package eop.project
import java.io.File;

import grails.test.GrailsUnitTestCase;

class LoaderServiceTest extends GrailsUnitTestCase {
	protected void setUp() {
		super.setUp()
	}
	protected void tearDown() {
		super.tearDown()
	}
	
	void testVolcanoDataLoading() {
		mockDomain (Volcano)
		mockDomain (Location)
		mockDomain (Damage)
		mockDomain (Eruption)
		def service = new LoaderService()
		LocalXmlService lservice = new LocalXmlService();
		service.loadVolcanoData (lservice)
		lservice.filePath =  'test/data/Volcano1.htm'
		Location location = Location.findByLocationName('Greece')
		assertNotNull location
		assertNotNull Volcano.findByLocation(location)
	}
	
	void testActivityDataLoading() {
		mockDomain (Volcano)
		mockDomain (Location)
		mockDomain (Damage)
		mockDomain (Eruption)
		mockDomain(Activity)
		Volcano v = new Volcano(volcanoName:'SAKURAJIMA'.toUpperCase(),volcanoType:'Stratovolcano',volcanicRef:'0804-191',status:'Holocene')
				
		v.save(flush:true)
		
		Eruption e = new Eruption(eventDate: new Date()) 
		e.volcano = v
		e.save(flush:true)
		
		
		def service = new LoaderService()
		LocalXmlService lservice = new LocalXmlService();
 		lservice.filePath =  'test/data/Volcanic ASH Advisories.htm'
		service.loadActivityData (lservice)
   }
	
}